package com.wz.project.surebarcode.sureBarcode.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.wz.framework.aspectj.lang.annotation.Log;
import com.wz.framework.aspectj.lang.enums.BusinessType;
import com.wz.project.surebarcode.sureBarcode.domain.Surebarcode;
import com.wz.project.surebarcode.sureBarcode.service.ISurebarcodeService;
import com.wz.framework.web.controller.BaseController;
import com.wz.framework.web.domain.AjaxResult;
import com.wz.common.utils.poi.ExcelUtil;
import com.wz.framework.web.page.TableDataInfo;

/**
 * 出库信息查询Controller
 * 
 * @author wld
 * @date 2023-10-20
 */
@Controller
@RequestMapping("/surebarcode/sureBarcode")
public class SurebarcodeController extends BaseController
{
    private String prefix = "surebarcode/sureBarcode";

    @Autowired
    private ISurebarcodeService surebarcodeService;

    @RequiresPermissions("surebarcode:sureBarcode:view")
    @GetMapping()
    public String sureBarcode()
    {
        return prefix + "/sureBarcode";
    }

    /**
     * 查询出库信息查询列表
     */
//    @RequiresPermissions("surebarcode:sureBarcode:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Surebarcode surebarcode)
    {
        startPage();
        List<Surebarcode> list = surebarcodeService.selectSurebarcodeList(surebarcode);
        return getDataTable(list);
    }

    /**
     * 导出出库信息查询列表
     */
    @RequiresPermissions("surebarcode:sureBarcode:export")
    @Log(title = "出库信息查询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Surebarcode surebarcode)
    {
        List<Surebarcode> list = surebarcodeService.selectSurebarcodeList(surebarcode);
        ExcelUtil<Surebarcode> util = new ExcelUtil<Surebarcode>(Surebarcode.class);
        return util.exportExcel(list, "sureBarcode");
    }

    /**
     * 新增出库信息查询
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存出库信息查询
     */
    @RequiresPermissions("surebarcode:sureBarcode:add")
    @Log(title = "出库信息查询", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Surebarcode surebarcode)
    {
        return toAjax(surebarcodeService.insertSurebarcode(surebarcode));
    }

    /**
     * 修改出库信息查询
     */
    @GetMapping("/edit/{stockoutGuid}")
    public String edit(@PathVariable("stockoutGuid") String stockoutGuid, ModelMap mmap)
    {
        Surebarcode surebarcode = surebarcodeService.selectSurebarcodeById(stockoutGuid);
        mmap.put("surebarcode", surebarcode);
        return prefix + "/edit";
    }

    /**
     * 修改保存出库信息查询
     */
    @RequiresPermissions("surebarcode:sureBarcode:edit")
    @Log(title = "出库信息查询", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Surebarcode surebarcode)
    {
        return toAjax(surebarcodeService.updateSurebarcode(surebarcode));
    }

    /**
     * 删除出库信息查询
     */
    @RequiresPermissions("surebarcode:sureBarcode:remove")
    @Log(title = "出库信息查询", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(surebarcodeService.deleteSurebarcodeByIds(ids));
    }
}
